
<h1>Timeline of object acquisitions</h1>

<% if @years.size > 0 %>
	<% first_year = @years.first.acquired_year %>
	<% last_year = @years.last.acquired_year %>

	<% year_data = Array.new %>
	<% year_labels = Array.new %>

	<% first_year.upto(last_year) do |year| %>

	<% year_count = nil %>
	

		<% @years.each do |y| %>
				<% if year == y.acquired_year %>
				<% year_count = y.count 	%>
				<% end %>
		<% end%>
	
		<% if year_count == nil %>	
			<% year_count = 0 %>
		<% end %>

		<% year_data << year_count.to_i %>
		<% year_labels << year %>
	<% end %>	


	<div class="chart"><%= google_chart("440x220", {:type => "lc", 
		:data => year_data, 
		:labels => year_labels
		}) 
		%></div>
		

		<% top_years = Array.new %>	
		<% @top_years.each do |year| %>
			<% top_years << [year.acquired_year, year.count] %>
		<% end%>
		<% top_years.sort! %>
		
		<div class="selected_data">
		<h2>Top years</h2>
		<ul class="years">
			<% top_years.each do |year| %>
			<li><%= link_to(year[0], museum_year_path(@museum, year[0])) %> <%= pluralize(year[1], "objects")%>
			<% end%>
		</ul>
		</div>
		<div style="clear: both;">&nbsp;</div>
		<% year_labels.each do |year| %> <%=link_to(year, museum_year_path(@museum, year)) %> <% end %>
<% end %>